﻿using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.Xml;
using _18miljard.Db;
using _18miljard.Mail;

namespace _18miljard.Daily
{
	public abstract class DailyJob
	{
		string logMessage = "";
		protected QueryCollection queries = new QueryCollection();
		protected BulkEMail emails = new BulkEMail();
		protected XmlNode jobNode;

		public DailyJob(XmlNode jobNode)
		{
			this.jobNode = jobNode;
		}

		public DailyJob(XmlNode jobNode, string logMessage)
			: this(jobNode)
		{
			this.logMessage = logMessage;
		}

		protected void OnStart()
		{
			LogWriter.Write(this.logMessage, false);
		}

		protected void OnEnd()
		{
			LogWriter.Write("Done.", false);
		}

		protected void OnError(Exception e)
		{
			LogWriter.Write(e);
		}

		public QueryCollection Queries
		{
			get { return this.queries; }
		}

		public BulkEMail Emails
		{
			get { return this.emails; }
		}

		public abstract void Execute();
	}
}
